<?php
/*******************************************************
*
* Page:    app_data.class
* Author:  Matthew Sturges (matt@matthewsturges.com)
* Purpose: Base class for database functionality
* Created: 06/29/05
* Version: 2.0
*
* Modified:
*    01/01/05 AAA  Sample modification notes
*
*******************************************************/

class app_data  {

    function connect(){
        $link = mysql_connect(APP_DATA_SERVER, APP_DATA_USERNAME, APP_DATA_PASSWORD) 
                       or die("Could not connect: " . $connectStr);
        mysql_select_db(APP_DATA_DATABASE) or die("Could not select database " . APP_DATA_DATABASE);
        return $link;
    }//end function

    function mysql_query($query){
        $result = mysql_query($query) or die ("<B style='color:red;'>Query failed.</b><br>"
                                              . $query . "<br><b>failed:</b>MySQL said: "
                                              . mysql_error());
        if (APP_DEBUG_LOG_SQL == 'on'){
            app_lib::log_to_file(APP_DEBUG_LOG_SQL_FILE, $query);
        }
        return $result;
    }


    function mysql_datetime($date) {
        $date = date('Y-m-d H:i:s', $date);
        return $date;
    }
    
    function flex_connect ($server, $username, $pass, $database) {
        $link = mysql_connect ($server, $username, $pass)
                or die ("Could not connect - Server: " . $server
                        . " User: " . $username);
        mysql_select_db ($database) or die ("Could not select database: " . $database);
    } // end function flex_connect

} //end class app_data

?>
